<template>
  <div class="WorkOrderDetail">
    <el-table
      :data="Detiallist"
      height="100%"
      :header-cell-style="{background:'#494e8f',color:'#ffffff'}"
      :row-class-name="tableRowClassName"
      row-key="id"
      border
      style="width: 100%">
      <el-table-column
        type="index"
        width="50">
      </el-table-column>
      <el-table-column
        prop="FEntrySelfY0280"
        label="前后道标志"
        width="120"
        show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        prop="FNumber"
        label="物料代码"
        width="180"
        show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        prop="FName"
        label="物料名称"
        width="180"
        show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        prop="FModel"
        label="规格"
        width="180"
        show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        prop="FUnit"
        label="单位"
        width="80">
      </el-table-column>
      <el-table-column
        prop="fql"
        label="缺料量"
        width="140">
      </el-table-column>
      <el-table-column
        prop="FAuxQtyMust"
        label="计划投料数"
        width="140">
      </el-table-column>
      <el-table-column
        prop="FQty"
        label="即时库存"
        width="140">
      </el-table-column>
      <el-table-column
        prop="FDiaobo"
        label="未调拨数量"
        width="140">
      </el-table-column>
      <el-table-column
        prop="FRuku"
        label="合格未入库"
        width="140">
      </el-table-column>
      <el-table-column
        prop="fqty1"
        label="本次锁定"
        width="140">
      </el-table-column>
      <el-table-column
        prop="fqty2"
        label="总锁定量"
        width="140">
      </el-table-column>
      <el-table-column
        prop="fqty3"
        label="未锁定量"
        width="140">
      </el-table-column>
      <el-table-column
        prop="ftidai"
        label="替代料量"
        width="130">
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  name: 'OrderLockDetail',
  props: ['OrderId', 'timestamp'],
  data () {
    return {
      dialogVisible: false,
      processType: '',
      fitemid: '',
      Detiallist: []
    }
  },
  created () {
    this.getOrderLockDetail()
  },
  watch: {
    timestamp: function () {
      this.getOrderLockDetail()
    },
    dialogVisible: function (newVal) {
      if (!newVal) {
        this.processType = ''
        this.fitemid = ''
      }
    }
  },
  methods: {
    tableRowClassName ({row, rowIndex}) {
      if (row.fql > 0) {
        return 'redDark-row'
      }
      return ''
    },
    getOrderLockDetail () {
      this.Detiallist = []
      this.Http.get('skDetailList', {finterid: this.OrderId}
      ).then(res => {
        switch (res.data.code) {
          case 1:
            this.Detiallist = res.data.orderDetiallist
            // this.Detiallist = res.data.orderDetiallist.map((item, idx) => {
            //   // 行首id
            //   item.id = idx
            //   if (item.orders && item.orders.length > 0 && item.fql > 0) {
            //     item.children1 = []
            //     item.orders.map((items, idxs) => {
            //       items.id = idx + '-' + idxs
            //       // 重组children与行首字段相同
            //       items.FNumber = item.FNumber && idxs === 0 ? item.FNumber : '' // 物料代码
            //       items.FName = item.FName && idxs === 0 ? item.Fname : '' // 物料名称
            //       items.FModel = item.FModel && idxs === 0 ? item.FModel : '' // 规格
            //       items.FUnit = item.FUnit && idxs === 0 ? item.FUnit : '' // 单位
            //       // items.FQty = (item.FQty || item.FQty === 0) && idxs === 0 ? item.FQty : '' // 库存
            //       items.FAuxQtyMust = (item.FAuxQtyMust || item.FAuxQtyMust === 0) && idxs === 0 ? item.FAuxQtyMust : '' // 计划投料数
            //       items.fql = (item.fql || item.fql === 0) && idxs === 0 ? item.fql : '' // 缺料数
            //       items.FQty = (item.FQty || item.FQty === 0) && idxs === 0 ? item.FQty : '' // 即时库存
            //       // items.fdateTxt = secondToFormat(items.fdate.time)
            //       // items.yifenpeikucun = (item.yifenpeikucun || item.yifenpeikucun === 0) && idxs === 0 ? item.yifenpeikucun : '' // 已分配库存

            //       // 缺料的第一行信息都补充完整
            //       if (idxs === 0) {
            //         item.fbillno = items.fbillno
            //         item.fqty = items.fqty
            //         item.fdateTxt = secondToFormat(items.fdate.time)
            //         item.fsupply = items.fsupply
            //         item.fuser = items.fuser
            //         item.yuqidays = items.yuqidays
            //       } else {
            //         // 添加children
            //         item.children1.push(items)
            //       }
            //     })
            //     // return item
            //   } else {
            //     // 同个单号的后面省略
            //   }
            //   return item
            // })
            break
          default:
            this.$message({
              message: res.data.message + '!',
              type: 'error'
            })
        }
      }).catch((error) => {
        console.log(error)
      })
    }
  }
}
</script>
<style lang="less" scoped>
/**
.WorkOrderDetail2{
  height: 400px;
  overflow-y: scroll;
}
**/
.WorkOrderDetail{
  height: 100%;
  background: pink;
}
th{
  padding:1px 4px;
  height: 20px;
  border-right: 1px solid #999;
  font-weight: normal !important;
  white-space:nowrap;
}
td{
  padding:1px 4px;
  min-height: 25px;
  border:0px solid #999;
  border-top: 1px solid #999;
  border-right: 1px solid #999;
  font-weight: normal !important;
  white-space:nowrap;
}
table{
  padding:0;
  min-height: 25px;
  line-height: 25px;
  border-collapse: collapse;
  border:1px solid #999;
  /**
  position: relative;
  **/
}
/**
tbody{
  width: 100%;
  display: block;
  height: 300px;
  overflow-y:scroll;
  position: absolute;
  top: 0;
  left: 0;
}
**/
</style>
